package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.home.PictureEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.ResolutionUtil;

import java.util.List;

/**
 * Created by wj on 2021/5/27 0005
 * Description：
 */
public class HomePicturePickAdapter extends BaseRecycleAdapter<PictureEntity> {

    private Context context;
    public HomePicturePickAdapter(Context context, List<PictureEntity> pictureEntityList) {
        super(context, R.layout.adapter_banner_item_pick, pictureEntityList);
        this.context = context;
    }

    @Override
    public void convert(ItemViewHolder holder, PictureEntity pictureEntity) {

        ImageView imageView = holder.itemView.findViewById(R.id.head_img);
        View view = holder.itemView.findViewById(R.id.head_hint);
        imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
        view.setVisibility(View.GONE);
        String icon = pictureEntity.getIcon();
        //判断是否存在
        if (!TextUtils.isEmpty(icon)) {
            if (icon.contains("http")) {
                Glide.with(context).load(pictureEntity.getIcon()).into(imageView);
            } else {
                switch (pictureEntity.getName()) {
                    case "招标大厅":
                        imageView.setBackgroundResource(R.drawable.bq_zbdt);
                        break;
                    case "招标公告":
                        imageView.setBackgroundResource(R.drawable.bq_zbgg);
                        break;
                    case "直接竞价":
                        imageView.setBackgroundResource(R.drawable.bq_zjjj);
                        break;
                    case "拍卖大厅":
                        imageView.setBackgroundResource(R.drawable.bq_pmdt);
                        break;
                    case "需求预告":
                        imageView.setBackgroundResource(R.drawable.bq_xqyg);
                        break;
                    case "招标预告":
                        imageView.setBackgroundResource(R.drawable.bq_zbyg);
                        break;
                    case "招采企业":
                        imageView.setBackgroundResource(R.drawable.bq_qyzx);
                        break;
                    case "中标公告":
                        imageView.setBackgroundResource(R.drawable.bq_zbgg1);
                        break;
                    case "现场竞标":
                        view.setVisibility(View.VISIBLE);
                        imageView.setBackgroundResource(R.drawable.bq_xcjb);
                        break;
                }
            }
        } else {
            Glide.with(context).load(R.drawable.user_center_def_img).into(imageView);
        }
    }
}
